﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Security.Permissions;
using System.ServiceModel;
using System.Text;

namespace VMDS.Security
{
    public static class VmdsRoleProvider
    {
       public static bool IsInRole(string role)
        {
          
            try
            {
                PrincipalPermission permPrincipal =
                    new PrincipalPermission (ServiceSecurityContext.Current.WindowsIdentity.Name, role,true);
                permPrincipal.Demand();
            }
            catch
            {
                throw new SecurityException();
               
            }
            return true;
        }

        
        static string getManagers()
        {
            return Environment.UserDomainName+"\\Виртуализация ФИ";
        }
        public static string Managers { get { return getManagers(); } }
       
        public static bool IsManager { get { return IsInRole(Managers); } }


    }
}
